#include <nvml.h>
#include <iostream>

int main() {
    nvmlInit();
    nvmlDevice_t device;
    nvmlDeviceGetHandleByIndex(0, &device);

    // 获取PCIe版本
    nvmlPcieInfo_t pcieInfo;
    nvmlDeviceGetPcieInfo(device, &pcieInfo);
    std::cout << "PCIe Generation: " << pcieInfo.pcieGen << " (Current: " << pcieInfo.pcieLink.current << ")" << std::endl;
    std::cout << "Link Width: " << pcieInfo.pcieLink.width << "x" << std::endl;

    nvmlShutdown();
    return 0;
}